<?php

/**
 * This is the model class for table "{{etudiant}}".
 *
 * The followings are the available columns in table '{{etudiant}}':
 * @property integer $id
 * @property string $numero_etudiant
 * @property string $programme
 * @property integer $promo
 * @property string $login_ece
 * @property string $prenom
 * @property string $nom
 * @property string $majeure
 * @property string $etage
 * @property string $option_de_sorite
 * @property string $option_va
 * @property string $mineure
 * @property string $rue1
 * @property string $rue2
 * @property string $cp
 * @property string $ville
 * @property string $pays
 * @property string $etat
 * @property string $tel
 * @property string $portable
 * @property string $email_ece
 * @property string $titre
 *
 * The followings are the available model relations:
 * @property StageContext[] $tblStageContexts
 * @property Stage[] $stages
 */
class Etudiant extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Etudiant the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{etudiant}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('numero_etudiant', 'required'),
			array('promo', 'numerical', 'integerOnly'=>true),
			array('numero_etudiant, majeure, etage', 'length', 'max'=>10),
			array('programme, login_ece', 'length', 'max'=>20),
			array('prenom, nom', 'length', 'max'=>30),
			array('option_de_sorite, option_va, mineure, rue1, rue2, cp, ville, pays, etat, tel, portable', 'length', 'max'=>45),
			array('email_ece', 'length', 'max'=>60),
			array('titre', 'length', 'max'=>15),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, numero_etudiant, programme, promo, login_ece, prenom, nom, majeure, etage, option_de_sorite, option_va, mineure, rue1, rue2, cp, ville, pays, etat, tel, portable, email_ece, titre', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'tblStageContexts' => array(self::MANY_MANY, 'StageContext', '{{etudiant_stageContext}}(etudiant_id, stageContext_id)'),
			'stages' => array(self::HAS_MANY, 'Stage', 'etudiant_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'numero_etudiant' => 'Numero Etudiant',
			'programme' => 'Programme',
			'promo' => 'Promo',
			'login_ece' => 'Login Ece',
			'prenom' => 'Prenom',
			'nom' => 'Nom',
			'majeure' => 'Majeure',
			'etage' => 'Etage',
			'option_de_sorite' => 'Option De Sorite',
			'option_va' => 'Option Va',
			'mineure' => 'Mineure',
			'rue1' => 'Rue1',
			'rue2' => 'Rue2',
			'cp' => 'Cp',
			'ville' => 'Ville',
			'pays' => 'Pays',
			'etat' => 'Etat',
			'tel' => 'Tel',
			'portable' => 'Portable',
			'email_ece' => 'Email Ece',
			'titre' => 'Titre',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('numero_etudiant',$this->numero_etudiant,true);
		$criteria->compare('programme',$this->programme,true);
		$criteria->compare('promo',$this->promo);
		$criteria->compare('login_ece',$this->login_ece,true);
		$criteria->compare('prenom',$this->prenom,true);
		$criteria->compare('nom',$this->nom,true);
		$criteria->compare('majeure',$this->majeure,true);
		$criteria->compare('etage',$this->etage,true);
		$criteria->compare('option_de_sorite',$this->option_de_sorite,true);
		$criteria->compare('option_va',$this->option_va,true);
		$criteria->compare('mineure',$this->mineure,true);
		$criteria->compare('rue1',$this->rue1,true);
		$criteria->compare('rue2',$this->rue2,true);
		$criteria->compare('cp',$this->cp,true);
		$criteria->compare('ville',$this->ville,true);
		$criteria->compare('pays',$this->pays,true);
		$criteria->compare('etat',$this->etat,true);
		$criteria->compare('tel',$this->tel,true);
		$criteria->compare('portable',$this->portable,true);
		$criteria->compare('email_ece',$this->email_ece,true);
		$criteria->compare('titre',$this->titre,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}